![require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages](https://cdn.sanity.io/images/cgdhsj6q/production/be8ab80c8efa5907bc341c6fefe9aa20d239d890-1600x1097.png?w=400&fit=max&auto=format)
Security News
require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
cobox-crypto
Advanced tools
The crypto primitives used in cobox, extracted into a separate module
npm install cobox-crypto
const Crypto = require('cobox-crypto')
const crypto = Crypto()
const accessKey = crypto.accessKey()
keyPair = crypto.keyPair()
Returns an ed25519
keypair that can used for tree signing.
const symKey = crypto.symmetricKey()
Returns an ed25519
symmetric key used for shared secret encryption
const accessKey = crypto.accessKey()
// OR
const accessKey = crypto.pack(pubKey, symKey)
Returns an access key, which consists of an ed25519
public key, packed together with an ed25519
symmetric key
const keys = crypto.unpack(key)
Returns an object containing a public key, and a shared secret if accessible. Public key alone is used for blind replication. The shared secret can then be used for decryption.
const valueEncoding = crypto.encoder(encryptionKey, {})
Returns a message encoder used for encrypting messages in hypercore. Can be passed to hypercore doing the following:
const accessKey = crypto.accessKey
const keys = crypto.unpack(accessKey)
var feed = hypercore(storage, keys.publicKey, {
valueEncoding: crypto.encoder(keys.symmetricKey, { valueEncoding: 'utf-8' })
})
feed.ready(() => {
feed.append("this is going to be encrypted", (err, seq) => {
// do other stuff...
})
})
const { publicKey, secretKey } = boxKeypair(seed)
const boxed = box(publicKey, message, [contextMessage])
Encrypts a message to a given public key and returns it as a buffer
publicKey
buffer or hex encoded stringmessage
buffer or hex encoded string of any lengthcontextMessage
, if passed, will be hashed in to the shared secret. Should be a buffer or hex encoded string.const unboxed = unbox(cipherText, keypair, [contextMessage])
Decrypts a message using the given keypair.
cipherText
the encrypted message given as a buffer.keypair
an object of the form { publicKey, secretKey }
both of which should be buffers or hex encoded strings.contextMessage
, if given, will be hashed into the shared secret. Should be a buffer or hex encoded string.FAQs
crypto encoding library for use in cobox
The npm package cobox-crypto receives a total of 1 weekly downloads. As such, cobox-crypto popularity was classified as not popular.
We found that cobox-crypto demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.